intro
by using the obsidian plugins QuickAdd and Templater, i can quickly make draft posts and later promote them to regular blog posts.
this is my "opinionated" way to do it, a bit silly, and there are other ways to do it, but c'est la vie.
QuickAdd setup
in QuickAdd i use a template (detailed below) with the following options:
this creates a new draft in /blog/drafts/
, using a template creatively named _obsidian_templates/blog_post_draft.md
.
executing this action prompts for a filename (the bit after the date and separator), resulting in something like /blog/drafts/2025-05-05 - some post.md
.
the draft opens in a new focused tab in obsidian, after some prompts.
the filename then gets used by the template to determine the frontmatter title
(more information in the next section).
new draft template
this template (blog_post_draft.md
) used by QuickAdd (above) has the following frontmatter block:
---
title: <% tp.file.title.split(" - ").slice(1).join(" - ") %>
date: <% tp.date.now('YYYY-MM-DDTHH:mm') %>
modified:
description: {{VALUE:description}}
tags:
<%*
let tagsArray = `{{VALUE:tags}}`.split(",").map(tag => ` - ${tag.trim()}`);
tR += tagsArray.join("\n");
%>
---
breaking it down:
title
title: <% tp.file.title.split(" - ").slice(1).join(" - ") %>
this takes the filename and turns it into the title
.
the split and slice and join is to split it all by instances of -
(space dash space), slice off the first section, then join the remaining pieces with -
(space dash space).
the reason i'm doing this is because i want all of my drafts and posts to have a filename of YYYY-MM-DD - title.md
(my preference, supported by the way i have QuickAdd create the files), but i also want to be able to have a space dash space in the title itself, if desired, and i don't want the date to be in the title
.
this means that something like
2025-05-05 - a post - part two.md
would result in frontmatter like
title: a post - part two
it's a personal choice and method for how i like to do filenames and titles.
no.
date
date: <% tp.date.now('YYYY-MM-DDTHH:mm') %>
this just inserts the current datetime in the date
field.
modified
this is left null on draft creation.
it gets populated automatically with the obsidian plugin update modified date as the content of the draft (or published post) is modified over time, in the same format as the date
.
description
description: {{VALUE:description}}
this is one of the prompted fields, filled in at time of draft creation. just a string.
tags
tags:
<%*
let tagsArray = `{{VALUE:tags}}`.split(",").map(tag => ` - ${tag.trim()}`);
tR += tagsArray.join("\n");
%>
another prompted field, then some transformation.
tags are entered comma separated in the prompt, then transformed from a standard array format into a one-per-line list format.
so, entering meow, test
into the prompt becomes tags: [meow, test]
which then becomes
tags:
- meow
- test
again this is all just personal preference and to ease compatibility and lower friction (read: cause me less hassle) for everything else.
frontmatter result
for the draft of this post, the raw frontmatter after creation might be like:
---
title: blog - obsidian templates and use
date: 2025-05-05T12:00
modified:
description: about the templates i use in obsidian to create drafts and posts
tags:
- blog
- obsidian
- templates
---
(the modified
value will get automatically updated as the post is worked on)
promoting drafts to posts
again, this is all very silly, but:
with a draft open and focused, i run the following template (_move_draft_to_blog.md
) via key combo (alt + e
):
<%*
// update the frontmatter with the current date
tp.hooks.on_all_templates_executed(async () => {
const file = tp.file.find_tfile(tp.file.path(true)); // the (t)file
await tp.app.fileManager.processFrontMatter(file, (frontmatter) => {
frontmatter["date"] = tp.date.now("YYYY-MM-DDTHH:mm"); // update 'date:'
frontmatter["modified"] = null; // null 'modified:'
});
});
// move the post into '/blog/' with appropriate filename
await tp.file.move("/blog/" + tp.date.now("YYYY-MM-DD") + " - " + tp.frontmatter.title);
%>
this:
- moves the file from
/blog/drafts/
into/blog/
, renamed with the current date (like2025-05-05 - title.md
) - updates the
date
value to the current date - nulls the
modified
value
the point of this is so that if i start a draft last week and promote it to a post today, it will be named and dated with today's date and a blank modified date.
this is so that a post's filename and date
will be when it was published, not when it was drafted, and so that the modified
won't be a time before the post was published (and modified
won't be present at all on the blog, initially, as it doesn't show when null)
modifying the post after it's officially a post will of course update the modified
value automatically, thanks to the obsidian plugin for handling that.
i need the filename, date
, and modified
to change and don't want to manually do it (read: automatically forget to do it)
outro
silly, sure, but a working kind of silly and working in a way i like.
i launch the QuickAdd action, fill in the info when prompted, start writing the draft.
i launch the templater action to promote it to a post with updated filename and date.
done.
i could likely do the draft to post promotion part through QuickAdd as well but to be honest i got it working this way and stopped messing with it.
that being said:
this method might change in the future and if so i will make a new post about whatever new silliness i'm doing then.
links
obsidian plugins mentioned (github links):